package com.bosc.automationui.controller;

import com.bosc.automationui.service.ETLDependencyService;
import com.bosc.automationui.service.ETLJobService;
import com.bosc.automationui.service.HDFSMonitorService;
import com.bosc.automationui.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@CrossOrigin
@RestController
public class MainController {

    @Autowired
    private ETLJobService etlJobService;

    @Autowired
    private JobService jobService;

    @Autowired
    private ETLDependencyService etlDependencyService;

    @Autowired
    private HDFSMonitorService hdfsMonitorService;

    @GetMapping("/overview")
    public HashMap<String, Object> getOverview() {
        return jobService.getOverview();
    }

    @PutMapping("/overview")
    public String sync() {
        return jobService.sync().toString();
    }

    @GetMapping(value = "/jobinfo")
    public HashMap<String, Object> getJobStatus() {
        return etlJobService.getList();
    }

    @GetMapping(value = "/dependency")
    public HashMap<String, Object> getAllDependency() {
        return etlDependencyService.getDependencyRecords();
    }

    @GetMapping(value = "/report")
    public String report() {
        return "feature dev in progress";
    }

    @GetMapping("/hdfs")
    public HashMap<String, Object>  testHdfs() {
        return hdfsMonitorService.getMonitorHistory();
    }
}
